/**
 * Created by chenweicheng on 19/6/18.
 */
/**
 * Created by chenweicheng on 15/7/17.
 */
import React, {PureComponent} from 'react'
import {
    View,
    Text,
    StyleSheet,
    Image,
    TouchableOpacity,
    NativeAppEventEmitter,
    Platform,
    Alert,
    TextInput,
    ScrollView
} from 'react-native'

import {NavigationActions} from 'react-navigation'
import {px2dpH, px2dpW} from '../config/px2dp'
import theme from '../config/theme'
import ModalDialog from '../widget/ModalDialog'
import ModalListDialog from '../widget/ModalListDialog'
import  ProtobufJsManager from "../proto/ProtobufJsManager"
import net from 'net';

import  UtilManager from "../util/UtilManager"
import  TcpManager from "../manager/TcpManager"

export  default class TestTcp extends PureComponent {
    static navigationOptions = ({navigation}) => ({

        headerTitle: 'TestTcp',

        headerRight: <View/>,
        headerStyle: theme.headerStyle,


    });


    constructor() {
        super();

        this.state = {
            reload: false
        }


        this.tcpsend = ""
    }

    reload() {
        this.setState({reload: !this.state.reload})
    }


    componentWillMount() {

    }


    send() {
        TcpManager.client.write(this.tcpsend);
    }


    ontcpsend(text) {
        this.tcpsend = text
        // console.log("ontcpsend", this.tcpsend)

    }

    render() {

        return (
            <View style={styles.container}>


                <TextInput
                    style={{width:px2dpW(240),height: 40, borderColor: 'gray', borderWidth: 1}}
                    onChangeText={this.ontcpsend.bind(this)}
                    defaultValue={this.tcpsend}
                    underlineColorAndroid={"transparent"}
                    placeholder={"tcpsend"}
                />
                <TouchableOpacity onPress={this.send.bind(this)}
                                  style={{height:50,width:120,backgroundColor:'#eeeeee',alignItems:'center',justifyContent:'center',margin:5}}>
                    <Text> send cmd</Text>
                </TouchableOpacity>


            </View>)
    }
}


const
    styles = StyleSheet.create({
        container: {
            flex: 1,
            backgroundColor: 'white',
            alignItems: 'center'

        }


    });
